<template>
    <div class="modal-mask" v-show="show" transition="modal">
        <div class="modal-confirm">
            <h2 class="confirm-header">
                <i class="iconfont icon-questioncircle"></i> {{ title }}
            </h2>
            <div class="confirm-content">
                {{ content }}
            </div>
            <div class="confirm-btns">
                <button v-show="showCancel" class="btn" @click="op('cancel')">取 消</button>
                <button v-show="showOk" class="btn btn-primary" @click="op('ok')">确 定</button>
            </div>
        </div>
    </div>
</template>

<script>
export default {

    data() {
        return {
            show: false,
            onCancel: false,
            onOk: false,
            showCancel:true,
            showOk:true,
            title: '提示',
            content: '内容',
            onOkParams: '',
            onCancelParmas:''
        };
    },
    methods: {
        alert(content) {
            this.content = content
            this.onOk = false
            this.onCancel = false
            this.showCancel = false
            this.show = true
            document.body.style.overflow = 'hidden'
        },
        op(type) {
            this.show = false
            if (type === 'cancel') {
                if (this.onCancel) this.onCancel(this.onOkParams)
            } else {
                if (this.onOk) this.onOk(this.onOkParams)
            }
            this.onCancel = false
            this.onOk = false
            document.body.style.overflow = ''
        }
    },
}
</script>

<style scoped>


article,
aside,
blockquote,
body,
button,
code,
dd,
details,
div,
dl,
dt,
fieldset,
figcaption,
figure,
footer,
form,
h1,
h2,
h3,
h4,
h5,
h6,
header,
hr,
input,
legend,
li,
menu,
nav,
ol,
p,
pre,
section,
td,
textarea,
th,
ul {
    margin: 0;
    padding: 0
}

body,
html {
    width: 100%;
    height: 100%;
    position: relative;
    color: #666
}

ol,
ul {
    list-style: none
}

body {
    font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    font-size: 1em
}

h2 {
    font-size: 1.5em
}

a {
    color: #2db7f5;
    text-decoration: none;
    transition: color .3s ease;
    cursor: pointer
}

a:hover {
    color: #4DC4F0
}


.modal-enter,
.modal-leave,
.popover-enter,
.popover-leave {
    opacity: 0
}

.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(55, 55, 55, .6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center
}

.modal-box,
.modal-confirm,
.popover-box {
    box-sizing: border-box;
    background-color: #fff
}

.confirm-content {
    padding:1.5em
}

.modal-confirm {
    width: 25em;
    padding: 2em 2em;
    border-radius: 1em;
    transition: transform .3s ease
}

.modal-transition,
.popover-transition {
    transition: all .3s ease
}

.modal-confirm i {
    color: #fa0;
    font-size: 2em;
    position: relative;
    top: 0.5em
}

.modal-confirm .confirm-btns {
    text-align: right
}

.btn-primary {
    color: #fff;
    background-color: #2db7f5;
    border-color: #2db7f5;
}
.btn {
    display: inline-block;
    margin-bottom: 0;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: 0.1em solid #d9d9d9;
    white-space: nowrap;
    line-height: 1.5;
    padding: 0.5em 1em;
    font-size: 1em;
    border-radius: 0.5em;
    -webkit-user-select: none;
    user-select: none;
    color: #666;
    outline: 0;
    background-color: #fff;
}
.btn-primary {
    color: #fff;
    background-color: #2db7f5;
    border-color: #2db7f5;
}
</style>
